<template>
  <div class="detail" v-show="isShow" transition="fade">
    <div class="detail-wrapp clearfix">
      <div class="detail-main">
        <h1 class="name">{{headerData.name}}</h1>
        <div class="star">
          <star :score="headerData.score" :size="48"></star>
        </div>
        <div class="title">
          <div class="line"></div>
          <div class="text">优惠信息</div>
          <div class="line"></div>
        </div>
        <ul v-if="headerData.supports" class="supports">
          <li class="support-item" v-for="(item,index) in headerData.supports" :key="index">
            <span class="icon" :class="classMap[headerData.supports[index].type]"></span>
            <span class="text">{{headerData.supports[index].description}}</span>
          </li>
        </ul>
        <div class="title">
          <div class="line"></div>
          <div class="text">商家公告</div>
          <div class="line"></div>
        </div>
        <div class="bulletin">
          <p class="content">{{headerData.bulletin}}</p>
        </div>
      </div>
    </div>
    <div class="detali-close" @click="closeClick">
      <i class="icon-close"></i>
    </div>
  </div>
</template>

<script>
import star from "../../components/content/star/star";
export default {
  name: "shopDetail",
  data() {
    return {
      isShow: false,
      classMap: []
    };
  },
  components: {
    star
  },
  props: {
    headerData: {
      type: Object,
      default: {}
    }
  },
  methods: {
    closeClick() {
      this.isShow = false;
    }
  },
  created() {
    this.classMap = ["decrease", "discount", "special", "invoice", "guarantee"];
  },
  mounted() {
    this.$Bus.$on("deatilShow", () => {
      this.isShow = true;
    });
  }
};
</script>

<style lang='stylus' scoped>
@import '../../common/stylus/mixins.styl'
.detail
  position: fixed
  z-index: 99
  width: 100%
  height: 100%
  overflow: auto
  background-color: rgba(7, 17, 27, 0.8)
  color: #fff
  transition: all 0.5s
  &.fade-transition
    opacity: 1
    background-color: rgba(7, 17, 27, 0.8)
  &.fade-enter, &.fade-leave
    opacity: 0
    background-color: rgba(7, 17, 27, 0)
  .detail-wrapp
    min-height: 100%
    width: 100%
    // 我们的最小高度就是页面高度
    .detail-main
      margin-top: 64px
      padding-bottom: 64px
      // 通过bottom给要插入的东西留下空间
      .name
        text-align: center
        height: 16px
        line-height: 16px
        font-size: 16px
        font-weight: 700
      .star
        text-align: center
        margin-top: 18px
      .title
        display: flex
        width: 80%
        margin: 28px auto
        .line
          flex: 1
          position: relative
          top: -6px
          border-bottom: 1px solid rgba(255, 255, 255, 0.5)
        .text
          padding: 0 12px
          font-weight: 700
          font-size: 14px
      .supports
        width: 80%
        margin: 0 auto
        .support-item
          padding: 0 12px
          margin-bottom: 12px
          font-size: 0
          &.last-child
            margin-bottom: 0
          .icon
            vertical-align: top
            display: inline-block
            margin-right: 6px
            width: 16px
            height: 16px
            background-size: 16px 16px
            background-repeat: no-repeat
            &.decrease
              bgimage('./img/decrease_2')
            &.discount
              bgimage('./img/discount_2')
            &.guarantee
              bgimage('./img/guarantee_2')
            &.invoice
              bgimage('./img/invoice_2')
            &.special
              bgimage('./img/special_2')
          .text
            font-size: 12px
            line-height: 16px
      .bulletin
        width: 80%
        margin: 0 auto
        .content
          padding: 0 12px
          line-height: 24px
          font-size: 12px
  .detali-close
    position: relative
    width: 32px
    height: 32px
    margin: -64px auto 0 auto
    // 通过负margin把要插入的东西，放进预留的padding里面
    clear: both
    font-size: 32px
</style>